import { foxconnClass } from './libvbar-s-dxfoxconn.so'
const foxconnObj = new foxconnClass();
const foxconn = {}

/**
 * initialization
 * @returns 0: Success / Non-zero: Failure
 */
foxconn.init = function () {
	return foxconnObj.init()
}

/**
 * Get Card Number
 * @returns cardNo: Success/Non-zero: Failure
 */
foxconn.getCardNum = function () {
	return foxconnObj.getCardNum()
}

/**
 * Card reader
 * @param {object} cardInfo Card information
 * @returns card:Success/Non-zero: Failure
 */
foxconn.readCard = function (cardInfo) {
	return foxconnObj.readCard(JSON.parse(cardInfo))
}

/**
 * Generate QR code
 * @param {string} baseUrl url
 * @param {string} sn Equipment identification
 * @param {string} deviceUsage  Strings ending with a null terminator: "0" = ACC (Access Control), "1" = ATT (Attendance).
 * @param {string} lon       A null-terminated string representing longitude (e.g., "118.672149").
 * @param {string} lat       A null-terminated string representing latitude (e.g., "32.075641").
 * @param {number} gpsRange Integers represent acceptable GPS radii, in meters.
 * @param {number} useLocation Check the GPS range of the user and device.
 * @returns qrcode:Success/Non-zero: Failure
 */
foxconn.generateQrcode = function (baseUrl, sn, deviceUsage, lon, lat, gpsRange, useLocation) {
	return foxconnObj.generateQrcode({baseUrl : baseUrl, mac : sn, deviceUsage : deviceUsage, lon : lon, lat : lat, gpsRange : gpsRange, useLocation : useLocation})
}

/**
 * Decrypt QR code
 * @param {string} baseUrl url
 * @param {string} sn Equipment identification
 * @returns qrcode:Success/Non-zero: Failure
 */
foxconn.processQrcode = function (qrcodeData) {
	return foxconnObj.processQrcode({qrcodeData : qrcodeData})
}

export default foxconn;
